<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>生命周期钩子</title>
</head>
<body>
  
</body>
<script>
export default defineComponent({
  name: "demo",
  props: {
    title: {
      type: String,
      default: "",
    },
  },
  //setup取消了beforeCreate和created在beforeCreate和created之前执行
  setup(porps, { emit }) {
    onBeforeMount(() => {
      console.log("onBeforeMount - 组件挂载到节点上之前执行的函数");
    });
    onMounted(() => {
      console.log("onMounted - 组件挂载完成后执行的函数");
    });
    onBeforeUpdate(() => {
      console.log("onBeforeUpdate - 组件更新之前执行的函数");
    });
    onUpdated(() => {
      console.log("onUpdated - 组件更新完成之后执行的函数");
    });
    onBeforeUnmount(() => {
      console.log("onBeforeUnmount - 组件卸载之前执行的函数");
    });
    onUnmounted(() => {
      console.log("onUnmounted - 组件卸载完成后执行的函数");
    });
    const state = reactive({
      //数据
      username: "",
      password: "",
      lowerCaseUsername: computed(() => state.username.toLowerCase()), //计算属性
    });
    //方法
    const fn= () => {};
    return {
      fn,
      onMounted,
      ...toRefs(state),
    };
  },
  computed: {},
  components: {},
  data() {
    return {};
  },
  methods: {},
});
</script>
</html>